#include "NFARule.h"




NFARule::NFARule(char start, char sym, char fin) 
    : from(start)
    , on(sym) 
    , to(fin)
{
}
   
NFARule::NFARule(const NFARule& t)
    : from(t.from)
    , on(t.on)
    , to(t.to)
{
}



    
NFARule& NFARule::operator=(const NFARule& t)
{
    NFARule tmp(t);
    swap(tmp);            
    return *this;
}        




bool NFARule::operator==(const NFARule& t) const 
{
    return ((t.from == from) && (t.on == on) && (t.to == to));
}

bool NFARule::operator!=(const NFARule& t) const
{
    return !(*this == t);
}    




string NFARule::toString()
{
    string str;
    str += from;
    str += " : ";
    if (on)
        str += on;
    if (to)
        str += to; 
    return str;
}     

void NFARule::swap(NFARule& t)
{
    char tmp;

    tmp = t.from;
    t.from = from;
    from = tmp;

    tmp = t.on;
    t.on = on;
    on = tmp;
        
    tmp = t.to;
    t.to = to;
    to = tmp;    
}
